var { mysql } = require('../qcloud')

// 获取组信息
module.exports = async (ctx, next) => {
    try {
        let res = await mysql('cGroup').select('groupid', 'groupname')
        if (Array.isArray(res) && res.length > 0) {
            ctx.state.data = res
            ctx.state.code = 200
        } else {
            ctx.state.data = 'query fail or data is null'
            ctx.state.code = 204
        }
    } catch (error) {
        ctx.state.data = error
        ctx.state.code = 409
    }
}
